package cn.itcast.quartz.job;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.Trigger;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class HelloJobTrigger implements Job {
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        String dateString = LocalDateTime.now().format(formatter);
        System.out.println("执行时间" + dateString);

        Trigger trigger = jobExecutionContext.getTrigger();
        System.out.println(trigger.getJobKey().getName());
        System.out.println(trigger.getJobKey().getGroup());
        System.out.println(trigger.getStartTime());
        System.out.println(trigger.getEndTime());
    }
}
